package com.aceitunaproject.server.unit;
import java.io.Serializable;

import com.aceitunaproject.server.entity.unit.Unit;
import com.aceitunaproject.server.player.Player;
import com.aceitunaproject.shared.exceptions.gamerules.IllegalActionException;
import com.sun.sgs.app.ManagedObject;

/**
 * Unit manager interface for handling unit-related operations
 * 
 * @author Maciej Miechowicz
 */
public interface UnitManager extends ManagedObject,Serializable{
	
	/**
	 * Moves an unit to a given X,Y coordinates on the world map
	 *  
	 * @param unitId id of the unit to move
	 * @param destinationX x coordinate of the destination tile
	 * @param destinationY y coordinate of the destination tile
	 */
	void moveUnit(long unitId,int destinationX,int destinationY) throws IllegalActionException;

	/**
	 * Moves an unit to a given X,Y coordinates on the world map
	 *  
	 * @param unit the unit to move
	 * @param destinationX x coordinate of the destination tile
	 * @param destinationY y coordinate of the destination tile
	 * @throws IllegalActionException 
	 */
	void moveUnit(Unit unit, int destinationX, int destinationY) throws IllegalActionException;
	
	/**
	 * Creates a new Unit and assigns it to a player
	 * @param name the name of the unit
	 * @param owner the player that will be assigned owner of the unit
	 * @param controller the player that will be assigned to be controller of the unit
	 * @return the new unit
	 */
	Unit CreateUnit(String name, Player owner, Player controller);

	/**
	 * Returns an Unit from its IDs
	 * @param unitID the Unit's unit id
	 * @return the unit with that id
	 */
	Unit getUnit(long unitID);

	/**
	 * Builds a settlement with the unit in the designated coordinates 
	 * 
	 * @param name the name of the new settlement
	 * @param unit the unit that will build the settlement
	 * @param settlementX designated coordinate x
	 * @param settlementY designated coordinate y
	 * 
	 */
	void buildSettlement(String name,Unit unit,int settlementX,int settlementY) throws IllegalActionException;

	/**
	 * Builds an unit with the given settlement 
	 * 
	 * @param name the name of the new unit.
	 * @param persons the number of persons the recruited unit will have.
	 * @param settlementId the id of the settlement where the unit will be recruited.
	 * @param player the player that recruits the unit.
	 * 
	 */
	Unit recruitUnit(long settlementId, String name, int persons, Player player)throws IllegalActionException;


}
